import { ref, watch } from 'vue';
import { useStore } from 'vuex';

// 操作方法 抽离出来
function options() {
  const store = useStore();
  const name = ref('酱紫出品');
  const inputValue = ref('');
  const add = () => {
    if (!inputValue.value) {
      return
    }
    store.commit('add', inputValue.value);
    inputValue.value = '';
  };
  const del = (i: any) => {
    store.commit('del', i * 1)
    console.log(i);
  };
  const update = (item: any, i: any) => {
    store.commit('updates', { index: i * 1, isfinished: !item.isfinished })
  }
  return { update, add, del, inputValue, name, store }
}

export default options